﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CodeTemplate2.Models.Employee;

namespace CodeTemplate2.Mapper.Employee
{
    public class JobTitleMapper
    {
        public EmployeeJobTitleModel Mapping(PositionService.PositionDto inputDto)
        {
            EmployeeJobTitleModel result = new EmployeeJobTitleModel
            {
                JobTitleId = inputDto.Id,
                JobTitleName = inputDto.Name
            };

            return result;
        }

        public static List<EmployeeJobTitleModel> GetJobTitleForDDL()
        {

            var result = new List<EmployeeJobTitleModel>();
            var service = new PositionService.PositionServiceClient();
            var list = service.GetAll(null);
            if (list.Data != null && list.Data.Length > 0)
            {
                foreach (var item in list.Data)
                {
                    result.Add(new EmployeeJobTitleModel
                    {
                        JobTitleId = item.Id,
                        JobTitleName = item.Name,
                    });
                }
            }
            return result;
        }
    }
}